{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
    "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5"
   },
   "source": [
    "# Intro of this notebook:\n",
    "In this notebook we are going to get familiar with Python. We will cover the basic portion of Python which can be very useful for Machine Learning. \n",
    "**A simple effort from me to make a Python bootcamp 3 Days for beginners who are enthusiastic about Machine Learning.**\n",
    "![Imgur](https://i.imgur.com/XcoYcRP.jpg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "05d884d19f368fed33913cac5c5688368eed7c72"
   },
   "source": [
    "## Now Lets Start!✌"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "93a9e5383efcd32e9c19b8932f330af35bc1ff2c"
   },
   "source": [
    "# &#128204; Code , Style, and Links"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "195c956676877a2b47ad9fe7ed5f73ea77e2e32c"
   },
   "outputs": [],
   "source": [
    "%%html\n",
    "<style>\n",
    "@import url('https://fonts.googleapis.com/css?family=Ewert|Roboto&effect=3d|ice|');\n",
    "body {background-color: gainsboro;} \n",
    "a {color: #000000; font-family: 'Roboto';} \n",
    "h1 {color: #000000; font-family: 'Orbitron'; text-shadow: 4px 4px 4px #aaa;} \n",
    "h2, h3 {color: slategray; font-family: 'Orbitron'; text-shadow: 4px 4px 4px #aaa;}\n",
    "h4 {color: #818286; font-family: 'Roboto';}\n",
    "span {font-family:'Roboto'; color:black; text-shadow: 5px 5px 5px #aaa;}  \n",
    "div.output_area pre{font-family:'Roboto'; font-size:110%; color:lightblue;}      \n",
    "</style>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_cell_guid": "79c7e3d0-c299-4dcb-8224-4455121ee9b0",
    "_uuid": "d629ff2d2480ee46fbb7e2d37f6b5fab8052498a",
    "collapsed": true
   },
   "source": [
    " ## &#128209; Table of Content :\n",
    " <b>Python Basic</b>\n",
    "*  Introduction of python\n",
    "* Features of Python programming language\n",
    "*  Implementation of python \n",
    "  *   Variables and Maths Operations\n",
    "  *   Casting\n",
    "  *   String\n",
    "  *   List\n",
    "  *   Tuples\n",
    "  *   Sets\n",
    "  *   Dictionaries\n",
    "  *   User Input"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "d977a207f51bc9c4fa815817c7751c0a49e92faf"
   },
   "source": [
    "## &#128214; 1. Python Basic \n",
    "![Imgur](https://i.imgur.com/POruZ9g.jpg?1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "2ae1b846cd469f4f532f9f20d5e0073bf12c33a3"
   },
   "source": [
    "## 1.1 Introduction of Python : \n",
    "Python is developed by Guido van Rossum. Guido van Rossum started implementing Python in 1989. Python is a general-purpose,\tobject-oriented\tand\topen source\tcomputer programming language, it is a high-level, human-readable and a\tcorresponding set of software tools and libraries.\n",
    "> Interesting fact: Python is named after the comedy television show Monty Python’s Flying Circus. It is not named after the Python snake."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "f5a2dbb3909c37f05f58f16fe9a52ea5fb191ca5"
   },
   "source": [
    "## 1.2 Features of Python programming language:\n",
    "1. **Readable:** Python is a very readable language.\n",
    "\n",
    "2. **Easy to Learn:** Learning python is easy as this is a expressive and high level programming language, which means it is easy to understand the language and thus easy to learn.\n",
    "3. **Cross platform: **Python is available and can run on various operating systems such as Mac, Windows, Linux, Unix etc. This makes it a cross platform and portable language.\n",
    "\n",
    "4. **Open Source:** Python is a open source programming language.\n",
    "\n",
    "5. **Large standard library:** Python comes with a large standard library that has some handy codes and functions which we can use while writing code in Python.\n",
    "\n",
    "6. ** Free:** Python is free to download and use. This means you can download it for free and use it in your application. See: Open Source Python License\n",
    "\n",
    "7. **Supports exception handling:** If you are new, you may wonder what is an exception? An exception is an event that can occur during program exception and can disrupt the normal flow of program. Python supports exception handling which means we can write less error prone code and can test various scenarios that can cause an exception later on.\n",
    "\n",
    "8. **Advanced features:** Supports generators and list comprehensions. We will cover these features later.\n",
    "\n",
    "9. **Automatic memory management:** Python supports automatic memory management which means the memory is cleared and freed automatically. You do not have to bother clearing the memory."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "5d42b3fcf80c5b2cbeaf29d301fd894c637df51f"
   },
   "source": [
    "## &#128187; 1.3 Implementation of Python :"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "df0a3c41439d0bf79a1ca0d606bdf066cb813e1d"
   },
   "source": [
    "# 1.3.1 How to Install Python:\n",
    "You can install Python on any operating system such as Windows, Mac OS X, Linux/Unix and others.\n",
    "\n",
    "To install the Python on your operating system, go to this [link](https://www.python.org/downloads/). You will see a screen like this.\n",
    "\n",
    "![Imgur](https://i.imgur.com/AOt6Jpu.png)\n",
    "\n",
    "This is the **official Python website** and it will detect the operating system and based on that it would recommend you to download Python. Here I am using Windows  so it gave me the download options for Python 2 and Python 3 for Windows. I would recommend you to download the ** latest version of Python 3 **(Python 3.7.2 in the screenshot).\n",
    "\n",
    "Installation steps are pretty simple. You just have to accept the agreement and finish the installation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "0d49ef8463e765cd1dd9c23de9cf532d77978ba8"
   },
   "source": [
    "# 1.3.1 Variables & Math Operations \n",
    "**Variables :**\n",
    "An equal (=) sign is used to store a value in a variable. Until then, we did not use any variables in the chapters. So whenever we press any key number, text or statement in the Python console and press Enter, its output shows the next line. But if we store a value in a variable (with the equal sign) and press enter, then the next line will not output. Rather, the right side of the equal sign will be stored in the variant on the left side of the equal sign, which we can use to name it in the next statement.\n",
    "Variable is like a small box made in computer memory, in which anything can be stored. When we declare a variable, the computer determines certain memory for that variable. Each variable's memory address is unique. The value of the program can be stored in the memory location filled in the name of the variable name. Once again, using that name, the value of that location can be accessed and used to be useful."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "c4a10dbe4646d49e3441443d119fd98e90a732ce"
   },
   "outputs": [],
   "source": [
    "X = 'Python is good for ML'\n",
    "print(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "c8883cd4532bbf85463729f4f3904d6810f53359"
   },
   "outputs": [],
   "source": [
    "ML = 5 \n",
    "print(ML)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "761ac3a1a00e8b29a6231f427ad1226b06bfcf6c"
   },
   "outputs": [],
   "source": [
    "DL= ML + 8 \n",
    "print(DL)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "c68b9c909ef9c8449ff18096573caed833d1274e"
   },
   "source": [
    "In the above example, initially, 'Python is good for ML' ( a string ) is stored in a variable X. In the next line, the print () function has been sent to the X as the argument. And we already know that if you send something as print function argument, then it is printed. So, ML number 5 is printed on screen. Similar works were done in print (ML + 8) line Here the print (5+ 8) is basically executed, because the value of ML is 5. And with the addition of 8 the number 13 has been sent as the print function argument which is printed on the screen."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "704b018ccd0aff40cf12686fdc84f0884383333c"
   },
   "source": [
    "**Math  Operations: ** Mathematical calculations can easily be done in Python Console."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "6224cc5c06a891b93ebba26fd9f5b8712424f739"
   },
   "source": [
    "**Operation** | **Operator** | \n",
    "------------ | ------------ | \n",
    "Addition |        +\n",
    "Subtraction |  -\n",
    "Multiplication | *\n",
    "Division | / \n",
    "Remainder| %\n",
    "Integer Division | // \n",
    "Exponentiation | **"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "89d0c489403c6cede9550ddf3bfb64ad17c6d90c"
   },
   "source": [
    "Under the following mathematical command, the results are easily found -"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "d066269b5aab373a88f83ee78528fd865c831a7f"
   },
   "outputs": [],
   "source": [
    "5+8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "1335550953f1e7a0c72e710bef907ca0ee1ba40e"
   },
   "outputs": [],
   "source": [
    "5+8-6"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "0e327bc0c84229bfeb2f89d7926d4259b51ef291"
   },
   "source": [
    "Just like the addition of subtraction, the work of multiplication can be easily done here. Using a bracket can be defined that any part of the operation will be done before the operation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "d73108876c545035817d9f4672c18b14401c196b"
   },
   "outputs": [],
   "source": [
    "5*(8+6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "a2f8a687570cf99d0546373979361207c7c82841"
   },
   "outputs": [],
   "source": [
    "8/6"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "742d6507225dd145d86332a3fc3bba92f18cb2b0"
   },
   "source": [
    "When using a single / share, the result comes in the float type decimal."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "5826f91baba0bce0b6f36b21c883dbf611176d8c"
   },
   "source": [
    "The addition of addition, subtraction, multiplication, there is support for expansion in Python, which we call a number to get on a number. This operation is done with two ** signs. For example -"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "d9f6866f748276d9c8468468855bd440516a1f8e"
   },
   "outputs": [],
   "source": [
    "5**8"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "b0584e4c06bebc4977fb894cd9588beab9a9ceec"
   },
   "source": [
    "The modulo operator is used only for determining the floor division and for determining the quotient. The floor division is done using two forward slashes **```//```** and the modulo operator is done with **```%```** symbol. See the example below -"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "50670986fcb7f5071b188c436d5cb024786498fe"
   },
   "outputs": [],
   "source": [
    "8//5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "fcf9b938801f12ed04c8657d2970bd52b9e99f32"
   },
   "outputs": [],
   "source": [
    "8%5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "abb4e503c63d4d77549ec29d2b990b10a8c2878c"
   },
   "source": [
    "# 1.3.2 Casting \n",
    "Casting Conversion means to convert variables from one type to another. It is a type of casting and is called. Python has some built-in functions for type casting. We can use them easily if we want to. Up until now we have learned about integers, floats, and strings data types. To convert this type, the functions are being respectively - **```int (), float, str ()```.**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "75caae5ebcc549cd3abbe7f3b2e8603d2225d901"
   },
   "source": [
    "**Integer casting:** The int () function is used to convert from strings or floats into angles."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "4b7eb4617abd2931dd25fc725d90ab8b937ce7d9"
   },
   "outputs": [],
   "source": [
    "int('458')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "75f975b12193b9a042dd8cf4e2def95fd570a45d"
   },
   "outputs": [],
   "source": [
    "int(58.4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "43d4f275bc9f49cbbc5488e3804ddcf1466ea326"
   },
   "source": [
    "**String casting:** Use the str () function without any restriction to convert it to any variable strings."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "3857df7c7bb0e7d8a081b44388fcee3c4b2942cd"
   },
   "outputs": [],
   "source": [
    "str(58)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "94d6189308dab5782e1582ff1d1fe8bd647c5578"
   },
   "outputs": [],
   "source": [
    "str(13)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "ff69e4633a72d4a3e1a8f2dae28659def801688e"
   },
   "source": [
    "When we write multiple variables inside the print () function, string converts should be used."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "3a51c7894422baa4279eb0ca829205832f051338"
   },
   "outputs": [],
   "source": [
    "print(\"Float = \" + str(8.4) + \" Integer = \" + str(45))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "50f71f316ba7f426ea0900e151d0e8e483b6835d"
   },
   "source": [
    "**Float casting:** The float () function is used to convert from strings or integers to float."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "426b08a020e78d6c318316da09ad80a682a6e19c"
   },
   "outputs": [],
   "source": [
    "float(58)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "258debcaae977c44ba2f90e0b8ffa8fd62ac63f0"
   },
   "outputs": [],
   "source": [
    "float(\"58.4\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "a007cfb2ebff206c7830893a7523945b05b333e2"
   },
   "source": [
    "# 1.3.3 String\n",
    "Strings are used in Python to record text information, such as name. Strings in Python are actually a sequence, which basically means Python keeps track of every element in the string as a sequence. For example, Python understands the string \"hello' to be a sequence of letters in a specific order. This means we will be able to use indexing to grab particular letters (like the first letter, or the last letter). \n",
    "\n",
    "In this lecture we'll learn about the following:\n",
    "\n",
    "1. Creating Strings\n",
    "\n",
    "2. Printing Strings\n",
    "\n",
    "3. Differences in Printing in Python 2 vs 3\n",
    "\n",
    "4. String Indexing and Slicing\n",
    "\n",
    "5. String Properties\n",
    "\n",
    "6. String Methods\n",
    "\n",
    "7. Print Formatting"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "ea519de848bb2ef44b632fb6e06dd00b730122de"
   },
   "source": [
    "####  1.Creating String \n",
    "To create a string in Python you need to use either single quotes or double quotes. For example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "7343ff0829858431f1a0cfcba0646a3365a6765e"
   },
   "outputs": [],
   "source": [
    "# Single word\n",
    "'Machine'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "948c2c60a557e2b0a48d91c97e39c84a8c2fd7f2"
   },
   "source": [
    " Entire phrase :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "bfaa8f2a291334e1bad910b9f15665a794143560"
   },
   "outputs": [],
   "source": [
    "'Python Bootcamp'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "16f19600f4c572822be8bdf04667324e0ce532c0"
   },
   "source": [
    "\n",
    " We can also use double quote:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "80c63530df69c52698d83a32ee11d9be9b666087"
   },
   "outputs": [],
   "source": [
    "\"Machine built  string with double quotes\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_kg_hide-input": false,
    "_uuid": "0cb465ec47f65611ecfbf36e2c79ff803b5501e6"
   },
   "source": [
    " Be careful with quotes! show in the below that: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "673da29c8665f8cd496256e2de80c25d1682a436"
   },
   "outputs": [],
   "source": [
    "'I'm using single quotes, but will create an error'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "bf6304d83596be516269148384d314fea15e03a6"
   },
   "source": [
    "\n",
    "The reason for the error above is because the single quote in I'm stopped the string. You can use combinations of double and single quotes to get the complete statement."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "219ccbe6f4de27867e0b560178c183c8905b5580"
   },
   "outputs": [],
   "source": [
    "\"Now I'm ready to use the single quotes inside a string By Machine!\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "baa31dcf7c55b7b057f884369daa907cba3a5d52"
   },
   "source": [
    "Now let's learn about printing strings!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "657560935189664d90669041ceae4b2783a5c693"
   },
   "source": [
    "#### 2.Printing a String\n",
    "Using Jupyter notebook with just a string in a cell will automatically output strings, but the correct way to display strings in your output is by using a print function."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "68a84c8c82c39621cf57610cd057ec877c8ff114"
   },
   "source": [
    "We can simply declare a string"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "d03b6c55bbca4d89177e19159cc92011248a0735"
   },
   "outputs": [],
   "source": [
    "'Hey Machine Learning'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "7bdecf829fd894df88dc5caf984df5eaedb47453"
   },
   "source": [
    "note that we can't output multiple strings this way"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "5870c1b1224c3c9668dccdaccd99ba0abc883478"
   },
   "outputs": [],
   "source": [
    "'Machine Learning'\n",
    "'Hey Machine Learning'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "ad2ba232d40f4f05993041c7883cc188186aa1b6"
   },
   "source": [
    "#### 3. Differences in Printing in Python 2 vs 3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "f944935cc7ea6f4ae458355c739734cb0164b4f5"
   },
   "source": [
    "We can use a print statement to print a string."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "5ed908afa9058bb5c2a39f3596c02bf0cb4a9b36"
   },
   "source": [
    "**Input Screen:**\n",
    "\n",
    "``print 'Machine Learning'\n",
    "print 'Hey Machine Learning'\n",
    "print 'Use \\n to print a new line'\n",
    "print '\\n'\n",
    "print 'See what I mean?``"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "47cf70011d02ca5f48102885175bb47e5cacf020"
   },
   "source": [
    "**Output Screen:**\n",
    "\n",
    "Machine Learning\n",
    "\n",
    "Hey Machine Learning\n",
    "\n",
    "Use \n",
    "\n",
    " to print a new line\n",
    "\n",
    "\n",
    "See what I mean?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "24a90645fc6d1a823d29c2a8b1d1ad71013895bf"
   },
   "source": [
    "Something to note. In Python 3, print is a function, not a statement. So you would print statements like this: print('Hello World')\n",
    "\n",
    "If you want to use this functionality in Python2, you can import form the future module."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "bee33509d75e8a0506dd9f5e7e4530ca6af642de"
   },
   "source": [
    "A word of caution, after importing this you won't be able to choose the print statement method anymore. So pick whichever one you prefer depending on your Python installation and continue on with it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "83b1cacd3b635d4627e23c9772c3a6f158aa9645"
   },
   "outputs": [],
   "source": [
    "# To use print function from Python 3 in Python 2\n",
    "from __future__ import print_function\n",
    "\n",
    "print('Hey Machine Learning')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "a5805bf25c3a106792e8bcce662cdab33762ee42"
   },
   "source": [
    "#### String Basics\n",
    "We can also use a function called len() to check the length of a string!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "3dddb5b27f51f501638626b71302342e8bf021ff"
   },
   "outputs": [],
   "source": [
    "len('Hey Machine')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "9016d09d6d3155c9fd8a9ae95026caeee4c7a868"
   },
   "source": [
    "#### 4. String Indexing and Slicing\n",
    "We know strings are a sequence, which means Python can use indexes to call parts of the sequence. Let's learn how this works.\n",
    "\n",
    "In Python, we use brackets [] after an object to call its index. We should also note that indexing starts at 0 for Python. Let's create a new object called s and the walk through a few examples of indexing."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "7a00631681f925cccbf7433a73e6c2f4ff5228b1"
   },
   "outputs": [],
   "source": [
    "# Assign s as a string\n",
    "M = 'Hey Machine'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "de75e6d2f16bdec21a4724af2e4e421ce3827113"
   },
   "outputs": [],
   "source": [
    "#Check\n",
    "M"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "62f590d053aa34427ffeb81220f0224439324169"
   },
   "outputs": [],
   "source": [
    "# Print the object\n",
    "print(M)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "e4aba68da5813bf5a1fd04b93b0b3d461850cc8d"
   },
   "source": [
    "Let's start indexing!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "d32a98f28ac6e0e11b8e5c804254940b09e3c02b"
   },
   "outputs": [],
   "source": [
    "M[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "81844aaf30825f79a730b85dcd90222fc9d509dd"
   },
   "outputs": [],
   "source": [
    "M[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "bd0fe7e8ffd9eeb5925063e7c0a848dc131d61df"
   },
   "outputs": [],
   "source": [
    "M[-2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "6348f327782cde6c1202c5636b6bd2ad13bf6168"
   },
   "source": [
    "\n",
    "We can use a : to perform slicing which grabs everything up to a designated point. For example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "37fde982dfb9182f0e4b38c4df4a21a8150b9593"
   },
   "outputs": [],
   "source": [
    "# Grab everything past the first term all the way to the length of M which is len(M)\n",
    "M[1:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "4276091926ae7f43308b850416b3509771366947"
   },
   "outputs": [],
   "source": [
    "# Note that there is no change to the original M\n",
    "M"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "26c84b2958f8fb8095eaef17a7ce9a197def66cb"
   },
   "outputs": [],
   "source": [
    "# Grab everything UP TO the 3rd index\n",
    "M[:3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "22b97bcb5d5746c509d3ee8e5ffb96d1b815cb10"
   },
   "source": [
    "Note the above slicing. Here we're telling Python to grab everything from 0 up to 3. It doesn't include the 3rd index. You'll notice this a lot in Python, where statements and are usually in the context of \"up to, but not including\"."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "0ac33a946b08832d78a878e9f17d83edab2ea153"
   },
   "outputs": [],
   "source": [
    "#Everything\n",
    "M[:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "9f43af5b866731b74c6f2ed1f327c59bd6983441"
   },
   "source": [
    "We can also use negative indexing to go backwards."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "025c64735f05e11971f1040557b19dee003be794"
   },
   "outputs": [],
   "source": [
    "# Last letter (one index behind 0 so it loops back around)\n",
    "M[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "c5989716972ad9ccb1c1e9531d6c248fcd88aecb"
   },
   "outputs": [],
   "source": [
    "# Grab everything but the last letter\n",
    "M[:-1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "636c3c3409815d40af89a21a05255db1a3ef7faf"
   },
   "source": [
    "We can also use index and slice notation to grab elements of a sequence by a specified step size (the default is 1). For instance we can use two colons in a row and then a number specifying the frequency to grab elements. For example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "e89c8f2fda2efefcc1db7ccc214497ac1d7eac55"
   },
   "outputs": [],
   "source": [
    "# Grab everything, but go in steps size of 1\n",
    "M[::1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "6ac1eb3cf568e737659dae58b5119dd76178dc24"
   },
   "outputs": [],
   "source": [
    "# Grab everything, but go in step sizes of 2\n",
    "M[::2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "06552bd858d240eed60b013282662055b8f23080"
   },
   "outputs": [],
   "source": [
    "# We can use this to print a string backwards\n",
    "M[::-1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "e2c363edcec02c805deec7e0c199555ece930a0d"
   },
   "source": [
    "####  5.String Properties\n",
    "Its important to note that strings have an important property known as immutability. This means that once a string is created, the elements within it can not be changed or replaced. For example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "f948288c953dd43b756dbf24fed2a67b853c7ebf"
   },
   "outputs": [],
   "source": [
    "M"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "77bff300eb08cec10163a676f4ca18639aedd66d"
   },
   "outputs": [],
   "source": [
    "# Let's try to change the first letter to 'x'\n",
    "M[0] = 'X'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "9d4e7067f0a1c350e22a36b4be233eaf42d0caf2"
   },
   "source": [
    "Notice how the error tells us directly what we can't do, change the item assignment!\n",
    "\n",
    "Something we can do is concatenate strings!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "d53082be111ee11fdb8d8f81fdddf9a98afea735"
   },
   "outputs": [],
   "source": [
    "M"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "b6254a5f59505de60ed969e2ce30a47b1a9238fe"
   },
   "outputs": [],
   "source": [
    "# Concatenate strings!\n",
    "M+' Learning!'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "fb24ed06a9b8c3920cee5b83d76632e755f1b737"
   },
   "outputs": [],
   "source": [
    "# We can reassign s completely though!\n",
    "M=M+' Learning!'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "d82c51c7369f1ec339ec67df29ab43beac8f41eb"
   },
   "outputs": [],
   "source": [
    "print(M)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "3e5fea3008f400519242c4911c827e20aa31bd2a"
   },
   "outputs": [],
   "source": [
    "M"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "4afec4e91acbbddb1676296b2f8872c23555c6b6"
   },
   "source": [
    "We can use the multiplication symbol to create repetition!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "c0e9c70241452365c36732f2b7a063bb47c6271c"
   },
   "outputs": [],
   "source": [
    "letter='M'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "94c5f7ceb43ab5f88f73883244c96a06d949cdf3"
   },
   "outputs": [],
   "source": [
    "letter*20"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "1d9056ca0984397ba0fe9d41f7a3e142ed00aa4e"
   },
   "source": [
    "#### 6.Basic Built-in String methods\n",
    "Objects in Python usually have built-in methods. These methods are functions inside the object (we will learn about these in much more depth later) that can perform actions or commands on the object itself.\n",
    "\n",
    "We call methods with a period and then the method name. Methods are in the form:\n",
    "\n",
    "object.method(parameters)\n",
    "\n",
    "Where parameters are extra arguments we can pass into the method. Don't worry if the details don't make 100% sense right now. Later on we will be creating our own objects and functions!\n",
    "\n",
    "Here are some examples of built-in methods in strings:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "725f55ac991734804ca39616d1be7033a5570fdc"
   },
   "outputs": [],
   "source": [
    "M"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "60c337a65f5330e0eb1578f916154733fb304323"
   },
   "outputs": [],
   "source": [
    "#Upper case a string\n",
    "M.upper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "09069382295a1538337f0c0ee1cf5336ba28eca3"
   },
   "outputs": [],
   "source": [
    "#Lower case a string\n",
    "M.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "f6c01ec3e39bbbe80ff68f769a5aa354bc5622ae"
   },
   "outputs": [],
   "source": [
    "# Split a string by blank space (this is the default)\n",
    "M.split()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "d19b8e8db4941242d63020e45fb01f4ef233c422"
   },
   "outputs": [],
   "source": [
    "# Split by a specific element (doesn't include the element that was split on)\n",
    "M.split('Learning')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "e8409e4a7b69296214b82d1fdbceb67998fd7fca"
   },
   "source": [
    "There are many more methods than the ones covered here. Visit the advanced String section to find out more!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "5cff9d99301ed77dc6a22841c9692c8a469cb7c6"
   },
   "source": [
    "#### 7.Print Formatting\n",
    "We can use the .format() method to add formatted objects to printed string statements.\n",
    "\n",
    "The easiest way to show this is through an example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "fcd0d2dd543e5c10a1f54ba551c0e1eeeebd0bc6"
   },
   "outputs": [],
   "source": [
    "'Insert another Bootcamp with curly brackets: {}'.format('The Machine Learning BootCamp!')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "9696e86ed950371b41682998cc136e349eadb36f"
   },
   "source": [
    "We will revisit this string formatting topic in later sections when we are building our projects!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "97baf36a2b0f55c338db96696b66d139c15422f8"
   },
   "source": [
    "# 1.3.4 List \n",
    "Lists are just like the arrays, declared in other languages. Lists need not be homogeneous always which makes it a most powerful tool in Python. A single list may contain DataTypes like Integers, Strings, as well as Objects. Lists are also very useful for implementing stacks and queues. Lists are mutable, and hence, they can be altered even after their creation.\n",
    "![Imgur](https://i.imgur.com/Ok9i6nm.png)\n",
    "In Python, list is a type of container in Data Structures, which is used to store multiple data at the same time. Unlike Sets, the list in Python are ordered and have a definite count. The elements in a list are indexed according to a definite sequence and the indexing of a list is done with 0 being the first index. Each element in the list has its definite place in the list, which allows duplicating of elements in the list, with each element having its own distinct place and credibility.\n",
    "\n",
    "Note- Lists are a useful tool for preserving a sequence of data and further iterating over it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "2ba6bf803b3527f95b94725b675c9f95ad894bcb"
   },
   "outputs": [],
   "source": [
    "names = [\"Pi\", \"Bike\", \"!\"]\n",
    "print(names[0])\n",
    "print(names[1])\n",
    "print(names[2])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "933b43cdbf320eb92d9ce5803c7001e788c1d02f"
   },
   "source": [
    "#### 1.3.4.1 Empty \n",
    "An empty list can be made as below - "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "b30afb13d66c72c47b189339aadb8d1a8d173bb0"
   },
   "outputs": [],
   "source": [
    "empty_list = []\n",
    "print(empty_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "852d2b733c21702ab7d85ab4445e052662f80b98"
   },
   "source": [
    "#### 1.3.4.2  Mixed List\n",
    "A mixed list can be made as below-"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "e6320dda5a08eed15362061603a95b8596c7d648"
   },
   "outputs": [],
   "source": [
    "mix_list = ['Pi', 3, 3.14, True]\n",
    "print (mix_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "4df095e21978af3fdf6f75f549a68dad2dd81673"
   },
   "source": [
    "#### 1.3.4.3  2D List or Matrix\n",
    "A 2D list of matrix can be made as below-"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "611ede39b8990af012a28beac930a4963c67275b"
   },
   "outputs": [],
   "source": [
    "matrix = [ [1, 2, 3, 4, 5],\n",
    "           [4, 5, 6, 7, 8],\n",
    "           [1, 1, 1, 1, 1],\n",
    "           [0, 0, 0, 0, 0]\n",
    "          ]\n",
    "print(matrix)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "e2bf58115427bec776efe503f1639a398234f8b7"
   },
   "source": [
    "#### 1.3.4.4 Nested list\n",
    "A nested list can be made as below-"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "80391c2677badd1ed2f8eb71a38d1cf5b6c79b13"
   },
   "outputs": [],
   "source": [
    "matrix = [ [2, 2, 3, 4, 4],\n",
    "           [4, 5, 6, 7, 9],\n",
    "           [1, 1, 1, 1, 1],\n",
    "           [0, 0, 0, 0, 0]\n",
    "          ]\n",
    "                    \n",
    "for x in matrix:\n",
    "    for y in x:\n",
    "        print (y, end=' ')\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "53596ddd7e74275aef1878c5146dc7f9bb6c63af"
   },
   "source": [
    "#### 1.3.4.5 List slicing\n",
    "A list slicing can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "7eb25d701333ab582aafb3599d6c2ae801bb428a"
   },
   "outputs": [],
   "source": [
    "numbers_list = [4, 5, 7, 8, 9]\n",
    "print ( numbers_list[0 : 2] )\n",
    "print ( numbers_list[2 : -2])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "266d4d24efbdec5bab642e9adcf5f04de184219a"
   },
   "source": [
    "#### 1.3.4.6 List iteration by for loop\n",
    "A list iteration by for loop can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "627f7cd81095b70dd9e3a8937c8b8107396316b7"
   },
   "outputs": [],
   "source": [
    "bikes = ['pibike', 'hellobike', 'mobike']\n",
    "for bike in bikes:\n",
    "    print (bike)\n",
    "    if (bike == 'hellobike'):\n",
    "        print (\"I love hellobike\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "6bd47da5786d9fe38846a0554223116f09b1c80a"
   },
   "source": [
    "#### 1.3.4.7  Sum of list numbers\n",
    "A  sum of list numbers can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "73823b4a942be8f10633f311dbd39da2d2eff08d"
   },
   "outputs": [],
   "source": [
    "list_of_number = [1, 7, 3, 4, 5]\n",
    "sum = 0\n",
    "for num in list_of_number:\n",
    "    sum += num\n",
    "print (\"Sum is: {sum}\".format(sum=sum))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "ab7386778b49d5d3278810ae317c82ba3a86de05"
   },
   "source": [
    "A sum of list numbers with string can be made as below---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "40dad38c84979ec19f872ca75b23bebbc890b9c2"
   },
   "outputs": [],
   "source": [
    "list_of_number = [1, 8, 'bike', 4, 5.5, 5]\n",
    "sum = 0\n",
    "for num in list_of_number:\n",
    "    if type(num) == int:\n",
    "        sum += num\n",
    "print (\"Sum is: {sum}\".format(sum=sum))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "33e893abe2f08cddbce1bf0386fd54c2563b1c20"
   },
   "source": [
    "#### 1.3.4.8  List modification\n",
    "A list modification can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "9248ae32425912c5e139ac88e57f64fda7528eed"
   },
   "outputs": [],
   "source": [
    "mix_list = ['mobike', 28, 5.4, True]\n",
    "print(mix_list)\n",
    "mix_list[0] = 'hellobike'\n",
    "print(mix_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "0f87f8481f5a468fd11269c5e02ae68bcb6ae92c"
   },
   "source": [
    "#### 1.3.4.9  Adding item in list\n",
    "A adding item in list can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "36c3918cd11b88556ee089c60249a0a1668da40d"
   },
   "outputs": [],
   "source": [
    "mix_list.append('pibike')\n",
    "print(mix_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "351276fb548461f891c5da440fbacdcaad4044be"
   },
   "outputs": [],
   "source": [
    "mix_list.insert(2, 'ofobike')\n",
    "print(mix_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "fdab7ff83b2455fe8391eff3ca26d1707c5c455c"
   },
   "outputs": [],
   "source": [
    "mix_list += ['ohbike'] # shortcut version for adding item\n",
    "print(mix_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "3e1cda4b84550d6e04e84b90fcd415d0b76e77cc"
   },
   "source": [
    "#### 1.3.4.10  Deleting item in list\n",
    "A  deleting item in list can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "04a12e2e24376473efd4ab1753b80b86c11bd5f9"
   },
   "outputs": [],
   "source": [
    "bikes = ['pibike', 'hellobike', 'mobike']\n",
    "del bikes[1]\n",
    "print( bikes )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "566014bc312576f4a3c36da14b7cb574dcdfa018"
   },
   "source": [
    "#### 1.3.4.11 Get and remove item using pop()\n",
    "A get and remove item using pop() can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "ee75c5ba7f70ffb15269c95baa973a5f3c3c9c75"
   },
   "outputs": [],
   "source": [
    "bikes = ['pibike', 'hellobike', 'mobike']\n",
    "last_bike=bikes.pop()# last item\n",
    "print(bikes, \"\\n\", last_bike)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "6763f11e24e0ceec16e2366ea460c547a7c53ddd"
   },
   "outputs": [],
   "source": [
    "bikes = ['pibike', 'hellobike', 'mobike']\n",
    "third_bike = bikes.pop(1) # third item\n",
    "print(bikes, \"\\n\", third_bike)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "d1d2fc09ca274822b366df9ac1539507d710d11f"
   },
   "source": [
    "#### 1.3.4.12 Splitting String into List items\n",
    "A splitting string into list items can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "e8d8ff108bd3cec70f40cabc35f3ce54db172948"
   },
   "outputs": [],
   "source": [
    "import re\n",
    "cars = \"toyota, hellobike, bmw, audi\"\n",
    "# cars = ['toyota', 'honda', 'bmw', 'audi']\n",
    "car_list = re.split(',', cars)\n",
    "print(car_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "69f6e79a45a559853ae528392ee84ea121c99bca"
   },
   "source": [
    "#### 1.3.4.13 List's string item concatnation\n",
    "A list's string item concatnation can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "69cc3097af7b275e35a6d6ba50e5c60c25ae91b4"
   },
   "outputs": [],
   "source": [
    "quote = ['Just', 'get','up','and','do','it,','follow','your','dreams!']\n",
    "print(quote)\n",
    "quote_str = ' '.join(quote)\n",
    "print(quote_str)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "b6ef4d7fa7dc43276b8767ef2397a7acbcd762ee"
   },
   "source": [
    "#### 1.3.4.14 List length \n",
    "A list length can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "8263d7e7484e6cf6bb8bb0589d2f5d21f51d23a6"
   },
   "outputs": [],
   "source": [
    "numbers = [1, 'bike', 3, 4]\n",
    "print (len(numbers))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "4521712656ab45f693aecd2e25169b9c9e12afdb"
   },
   "source": [
    "#### 1.3.4.15 Reversing list\n",
    "A reversing list can be made as below--"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "fbf2fcb0cd7b364a61f328bf1e99ec4c0caaf446"
   },
   "outputs": [],
   "source": [
    "reverse_list = ['Mobike', 'Hellobike', 3, 4]\n",
    "reverse_list.reverse()\n",
    "print(reverse_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "dc2c128a2cf6efc6bad11833cd31c9200a553b2e"
   },
   "source": [
    "### 1.3.4.16 List Comprehensions \n",
    "In addition to sequence operations and list methods, Python includes a more advanced operation called a list comprehension.\n",
    "![Imgur](https://i.imgur.com/O14brf9.png)\n",
    "List comprehensions allow us to build out lists using a different notation. You can think of it as essentially a one line for loop built inside of brackets."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "c663e1b693333dcf4565225e057523e5a6b18581"
   },
   "outputs": [],
   "source": [
    "lst = [ x**2 for x in [x**2 for x in range(11)]]\n",
    "lst"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "f231ec53b5238e9e2445aee607ebc39b5c95147c"
   },
   "source": [
    "# 1.3.5 Tuples \n",
    "A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.\n",
    "\n",
    "Creating a tuple is as simple as putting different comma-separated values. Optionally you can put these comma-separated values between parentheses also.\n",
    "![Imgur](https://i.imgur.com/dWSQIZo.png)\n",
    "In this section, we will get a brief overview of the following:\n",
    "\n",
    "1.Constructing Tuples\n",
    "\n",
    "2.Basic Tuple Methods\n",
    "\n",
    "3.Immutability\n",
    "\n",
    "4.When to Use Tuples.\n",
    "\n",
    "You'll have an intuition of how to use tuples based on what you've learned about lists. We can treat them very similarly with the major distinction being that tuples are immutable."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "334af29fc59aec8962ac744577786ef6e9c36a21"
   },
   "source": [
    "### 1. Constructing Tuples \n",
    "The construction of a tuples use () with elements separated by commas. For example:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "a43cd24c91265527c6ab6e9d792c55e60cadce2f"
   },
   "source": [
    "Can create a tuple with mixed types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "2785779460c42ba46f876a942066363c93fa365d"
   },
   "outputs": [],
   "source": [
    "t = (4,5,7,9)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "af0e915ef4f679c2735c07b75e973353764a2019"
   },
   "source": [
    "Check len just like a list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "c998ebbeba32d5aac7454e28b0d9afe66ef840a2"
   },
   "outputs": [],
   "source": [
    " len(t)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "e878f95f88da4aa2ca6ff2a165841d544e86313c"
   },
   "source": [
    "Can also mix object types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "13f13bf6d6db1d5cc82a99bfbd7c87530cde3017"
   },
   "outputs": [],
   "source": [
    "t = ('five',2)\n",
    "t"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "6b001dbe95c29d08d4b70a8252ab68d00693b477"
   },
   "source": [
    "Use indexing just like we did in lists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "9a627df633f637671c0375254bb3c31cb464e136"
   },
   "outputs": [],
   "source": [
    "t[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "6b5455006c06ba597332bb6125420f727e549c4c"
   },
   "source": [
    "Slicing just like a list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "5b04b2a0593cb641da20cd964ae62f5fc0ba93af"
   },
   "outputs": [],
   "source": [
    "t[-1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "fd8f54281653988248077f10ca9e93a70c9c7fef"
   },
   "source": [
    "### 2.Basic Tuple Methods\n",
    "Tuples have built-in methods, but not as many as lists do. Lets look at two of them:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "0d042b6b113a2fdf445c3a15d44421ea1ee385b3"
   },
   "outputs": [],
   "source": [
    "# Use .index to enter a value and return the index\n",
    "t.index('five')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "b396e08ce6800558d35bc6e0f8270b4b3be9bc56"
   },
   "outputs": [],
   "source": [
    "# Use .count to count the number of times a value appears\n",
    "t.count('four')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "9bc4fe6ac5da0abc0885d1f0b6e1fa834a2fbe8a"
   },
   "source": [
    "### 3.Immutability\n",
    "It can't be stressed enough that tuples are immutable. To drive that point home:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_kg_hide-input": true,
    "_uuid": "118f6f6eb4fa3104f675f478baf080d91e68476d"
   },
   "outputs": [],
   "source": [
    "t[0]= 'change'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "047a43ce5003dd7716ef7768094aa5f8e444faf7"
   },
   "source": [
    "Because of this immutability, tuples can't grow. Once a tuple is made we can not add to it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "c0c0c7326dbc58972afb12246a8ce364d557bf73"
   },
   "outputs": [],
   "source": [
    "t.append('nope')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "4ae469fb7f5408fcbb0363cd27a1c011d281999e"
   },
   "source": [
    "### 4. When to use Tuples\n",
    "You may be wondering, \"Why bother using tuples when they have fewer available methods?\" To be honest, tuples are not used as often as lists in programming, but are used when immutability is necessary. If in your program you are passing around an object and need to make sure it does not get changed, then tuple become your solution. It provides a convenient source of data integrity.\n",
    "\n",
    "You should now be able to create and use tuples in your programming as well as have an understanding of their immutability."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "c3fa4ee68d7c766f738caec32779ee846dfe27c3"
   },
   "source": [
    "# 1.3.6 Sets\n",
    "A set is an unordered collection of items. Every element is unique (no duplicates) and must be immutable (which cannot be changed).However, the set itself is mutable. We can add or remove items from it.Sets can be used to perform mathematical set operations like union, intersection, symmetric difference etc.\n",
    "![Imgur](https://i.imgur.com/MzFKDv6.png)\n",
    "Sets are an unordered collection of unique elements. We can construct them by using the set() function. Let's go ahead and make a set to see how it works:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "dbce2da586b17c53902680ec2a9984fb71006c39"
   },
   "outputs": [],
   "source": [
    "x = set()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "31b7f2b0dc6282a87fec9f22e10016a6a341fca2"
   },
   "outputs": [],
   "source": [
    "# We add to sets with the add() method\n",
    "x.add(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "7a0ac07420a0edf4ac46243da67be8e11940111c"
   },
   "outputs": [],
   "source": [
    "#Show\n",
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "f3b956f965feafd9984ffdd92a5a8ad7f8130e0f"
   },
   "source": [
    "Note the curly brackets. This does not indicate a dictionary! Although you can draw analogies as a set being a dictionary with only keys.\n",
    "\n",
    "We know that a set has only unique entries. So what happens when we try to add something that is already in a set?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "d4d5bbde4de7474baafac797453cf7b396cd8e5b"
   },
   "outputs": [],
   "source": [
    "# Add a different element\n",
    "x.add(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "0942596de080cb09e83b161695a0a2753ee6663d"
   },
   "outputs": [],
   "source": [
    "#Show\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "26f417372e7c4bb5d838c23d82f13e5e2f666b42"
   },
   "outputs": [],
   "source": [
    "# Try to add the same element\n",
    "x.add(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "7d73d04e74794d1c673a1c77744e5bb22eae79f5"
   },
   "outputs": [],
   "source": [
    "#Show\n",
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "4c79ec325d42af0d7eec3c33827391b5eb990c52"
   },
   "source": [
    "Notice how it won't place another 1 there. That's because a set is only concerned with unique elements! We can cast a list with multiple repeat elements to a set to get the unique elements. For example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "4b940d69dbe724b4f3603ebc1e253f3413bc9d1f"
   },
   "outputs": [],
   "source": [
    "# Create a list with repeats\n",
    "l = [1,1,2,2,3,4,5,6,1,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "6ac35b3a59c11a9833f05e3b4025412d82605e35"
   },
   "outputs": [],
   "source": [
    "# Cast as set to get unique values\n",
    "set(l)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "382b55ef6f3d87ccaa4d8dd8d2a342692c5078d8"
   },
   "source": [
    "### 1.3.6.1 Set Union\n",
    "Union of A and B is a set of all elements from both sets.\n",
    "Union is performed using ``|`` operator. Same can be accomplished using the method ``union()``."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "e55992e7f09587b317d9bc156892a37b60a1b979"
   },
   "outputs": [],
   "source": [
    "# initialize A and B\n",
    "A = {4, 5, 6, 4, 5}\n",
    "B = {4, 5, 6, 7, 8}\n",
    "# use | operator\n",
    "print(A | B)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "495c1f6d081bbff0c62d80a09ed414668b2ebb12"
   },
   "source": [
    "### 1.3.6.2 Set Intersection\n",
    "Intersection of A and B is a set of elements that are common in both sets.\n",
    "Intersection is performed using ``&`` operator. Same can be accomplished using the method ``intersection()``."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "1ad69f9ae08976d9fa655f38a5838da5c9aca036"
   },
   "outputs": [],
   "source": [
    "# initialize A and B\n",
    "A = {8, 9, 3, 4, 5}\n",
    "B = {4, 5, 6, 7, 8}\n",
    "# use & operator\n",
    "print(A & B)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "337ff275939084d149e7c8bcc065a3eb7c0a8c65"
   },
   "source": [
    "### 1.3.6.3 Set Difference\n",
    "Difference of A and B (A - B) is a set of elements that are only in A but not in B. Similarly, B - A is a set of element in B but not in A.Difference is performed using ``-``operator. Same can be accomplished using the method ``difference()``."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "9635f7c705166027632a394100e179296597ee83"
   },
   "outputs": [],
   "source": [
    "# initialize A and B\n",
    "A = {13, 8, 3, 4, 5}\n",
    "B = {4, 5, 6, 7, 8}\n",
    "# use - operator on A\n",
    "print(A - B)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "9716e4dda168d2f356ad141ef61e5fc8a6cd6726"
   },
   "source": [
    "### 1.3.6.4 Set Symmetric Difference\n",
    "Symmetric Difference of A and B is a set of elements in both A and B except those that are common in both.Symmetric difference is performed using ``^`` operator. Same can be accomplished using the method ``symmetric_difference()``."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "0c61fbb420893fb20e43ac0d94931adb8aa9d3d4"
   },
   "outputs": [],
   "source": [
    "# initialize A and B\n",
    "A = {13, 18, 3, 4, 5}\n",
    "B = {4, 5, 6, 7, 8}\n",
    "# use ^ operator\n",
    "print(A ^ B)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "7d94d30ea2500338b48a40611957060609fd36d9"
   },
   "source": [
    "# 1.3.7 Dictionaries\n",
    "Python dictionary is an unordered collection of items. While other compound data types have only value as an element, a dictionary has a key: value pair.Dictionaries are optimized to retrieve values when the key is known.\n",
    "![Imgur](https://i.imgur.com/XDoXiGy.png)\n",
    "We've been learning about sequences in Python but now we're going to switch gears and learn about mappings in Python. If you're familiar with other languages you can think of these Dictionaries as hash tables.\n",
    "This section will serve as a brief introduction to dictionaries and consist of:\n",
    "1. Constructing a Dictionary\n",
    "\n",
    "2. Accessing objects from a dictionary\n",
    "\n",
    "3. Nesting Dictionaries\n",
    "\n",
    "4. Basic Dictionary Methods\n",
    "\n",
    "A Python dictionary consists of a key and then an associated value. That value can be almost any Python object."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "062054ed36bf89c061cc6fd3913f2845870f7cdd"
   },
   "source": [
    "### 1 Constructing a Dictionary\n",
    "Let's see how we can construct dictionaries to get a better understanding of how they work!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "f8ad168853106b257568315c11947705306c52ce"
   },
   "outputs": [],
   "source": [
    "# Make a dictionary with {} and : to signify a key and a value\n",
    "my_dict = {'key1':'value1','key2':'value2'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "443e0f6430d0561d7f35daed5b1cc25001c14831"
   },
   "outputs": [],
   "source": [
    "# Call values by their key\n",
    "my_dict['key2']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "8cfe206ae9056c391d13891cb43d1c744253aed6"
   },
   "source": [
    "Its important to note that dictionaries are very flexible in the data types they can hold. For example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "4033d1a932517e0a3f7008e5962e7010a1ae3041"
   },
   "outputs": [],
   "source": [
    "my_dict = {'key1':123,'key2':[12,23,33],'key3':['item0','item1','item2']}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "db9dff4982287d60e00e9f11f3bce2e87fae4e8d"
   },
   "outputs": [],
   "source": [
    "#Lets call items from the dictionary\n",
    "my_dict['key3']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "a3f7dacbe50c3ca2b31f536cb51643f02af52970"
   },
   "outputs": [],
   "source": [
    "# Can call an index on that value\n",
    "my_dict['key3'][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "f62bd33cdf50b5249195690d28d1e4e393b2c890"
   },
   "outputs": [],
   "source": [
    "#Can then even call methods on that value\n",
    "my_dict['key3'][0].upper()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "fdcdcf25fac5899fe38d74ef2cd737b8b84aa269"
   },
   "source": [
    "A quick note, Python has a built-in method of doing a self subtraction or addition (or multiplication or division). We could have also used += or -= for the above statement. For example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "96d8e9abbfb574a8be5165a85700efd4fe1fff7e"
   },
   "outputs": [],
   "source": [
    "# Set the object equal to itself minus 123 \n",
    "my_dict['key1'] -= 123\n",
    "my_dict['key1']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "d3b2d35982471bf7a0c43a192bc7b9b06c670336"
   },
   "source": [
    "### 2. Accessing objects from a dictionary\n",
    "We can also create keys by assignment. For instance if we started off with an empty dictionary, we could continually add to it:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "13b6fe66fb97858e5ad9dcfbb267092c3b6720eb"
   },
   "outputs": [],
   "source": [
    "# Create a new dictionary\n",
    "d = {}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "13eb5db4a04f851ff33e9ce291cf97f54954faea"
   },
   "outputs": [],
   "source": [
    "# Create a new key through assignment\n",
    "d['animal'] = 'Dog'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "095e3ad22ec8d092feceb9a2250e2a4652c5a6c9"
   },
   "outputs": [],
   "source": [
    "# Can do this with any object\n",
    "d['answer'] = 52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "65bed09ad9ef54540f78c36c7aba12bc916bcb86"
   },
   "outputs": [],
   "source": [
    "#Show\n",
    "d"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "5d5a92b82dd06a645345133e648ff44730574977"
   },
   "source": [
    "### 3.Nesting with Dictionaries\n",
    "Hopefully you're starting to see how powerful Python is with its flexibility of nesting objects and calling methods on them. Let's see a dictionary nested inside a dictionary:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "724e540c3df3b905061a56043cef77e78b0edb2a"
   },
   "outputs": [],
   "source": [
    "# Dictionary nested inside a dictionary nested in side a dictionary\n",
    "d = {'key1':{'nestkey':{'subnestkey':'value'}}}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "ec0906015722362e1e2a6fce6ee0c599019a062c"
   },
   "source": [
    "Wow! That's a quite the inception of dictionaries! Let's see how we can grab that value:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "4eb581c533bd93a05638a52636e9fcc0b562c80d"
   },
   "outputs": [],
   "source": [
    "# Keep calling the keys\n",
    "d['key1']['nestkey']['subnestkey']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "d7e6119d13c0e4aa9482260ef233fa7c14541740"
   },
   "source": [
    "### 4.Basic Dictionary Methods\n",
    "There are a few methods we can call on a dictionary. Let's get a quick introduction to a few of them:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "9d8fb566a88228bb838ca410d9b2fca056e4e666"
   },
   "outputs": [],
   "source": [
    "# Create a typical dictionary\n",
    "d = {'key1':13,'key2':47,'key3':3}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "bd9a776b1f04c1230bb4b6614ab5d12527eca210"
   },
   "outputs": [],
   "source": [
    "# Method to return a list of all keys \n",
    "d.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "fe822733cb4251c13b0f245f2fb145d503bacd8f"
   },
   "outputs": [],
   "source": [
    "# Method to grab all values\n",
    "d.values()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "_uuid": "9e352a2fd88881055d7f5827cf7dfc2bc7f881de"
   },
   "outputs": [],
   "source": [
    "# Method to return tuples of all items  (we'll learn about tuples soon)\n",
    "d.items()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "eafea2aff177a00e1ff16415493d3592d8c00c67"
   },
   "source": [
    "Hopefully you now have a good basic understanding how to construct dictionaries. There's a lot more to go into here, but we will revisit dictionaries at later time. After this section all you need to know is how to create a dictionary and how to retrieve values from it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "7012bbb1e98ef7d26c5ec11b2b743739ac468ecd"
   },
   "source": [
    "## 1.3.8 User Input\n",
    "Use Python's input() function to accept user input. You can then use this input within your program.You can write Python programs that accept user input. You could ask the user their name, their age, or pretty much anything. The user's input can then be used within your program in any number of ways. You could simply print their input back to the screen, you could insert it into a database, or you make the program do different things depending on the input received.\n",
    "![Imgur](https://i.imgur.com/bv3sI3h.jpg)\n",
    "Here's a basic example of using the ```input()``` function:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "f2a6de523ad76c7bb248aa7227206f430595e313"
   },
   "source": [
    "![Imgur](https://i.imgur.com/UrfOLSf.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "94182d8be0e684360ca576ffb00b060d0229420f"
   },
   "source": [
    "As with any variable, you can also combine the user's input with other text, like this:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "1d483754704b0fa7d03b887b3a70b37b1a55e1d6"
   },
   "source": [
    "![Imgur](https://i.imgur.com/7n1W74Q.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "_uuid": "a70257ae60fb5f2473f9da9bf8a03f11a861f3db"
   },
   "source": [
    "# Conclusion:\n",
    "Thanks for reading this Bootcamp's notebook. If you have any suggestion feel free to reach me in the comment or [sent mail](harunspeedy1995@gmail.com) or connect on [LinkedIn](https://www.linkedin.com/in/harun-ur-rashid6647/). Stay in touch for more update and Python Bootcamp Part-2 & Part-3. Thank you. 😎\n",
    "![Imgur](https://i.imgur.com/DqK5lrP.jpg)\n",
    "For the full code visit [Github](https://github.com/harunshimanto/Python-Bootcamp-with-ML) \n",
    "If you like this Bootcamp then give 👍 upvote. Happy Bootcamp!."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
